#ifndef __NETWORK_SOCKET_H__
#define __NETWORK_SOCKET_H__


#define NETWORK_CARD_NAME "eth0"
#define SOCKET_GROUP_PORT 8848
#define SOCKET_GROUP_IP   "225.1.1.1"    /* 组播地址为224.0.0.0到239.255.255.255之间的任意一个地址 */
#define CMD_PACKAGE_LEN 128


typedef struct{
    int base;
    int unit;   /* 栋 */
    int floor;  /* 层 */
    int index;  /* id */
    char type;  /* 类型 */
    char byname[64]; /* 别名 */

    int ip[4];

    unsigned int  identifier;   /* 编号 */

} SOCKET_DEVICE_STRUCT;


typedef struct{
    char cmd;
    unsigned int arg1;
    unsigned int arg2;
    char text[64];
    char addr[20];

}socket_cmd_send_device_struct;

typedef struct{
    char *str;
    unsigned char cmd;
    void (*send_function)(socket_cmd_send_device_struct *info);
    void (*recv_function)(socket_cmd_send_device_struct *info);
} socket_cmd_recv_struct;



typedef enum{
    SOCKET_CMD_START = 0xAA,
    SOCKET_CMD_END   = 0xFF,

    SOCKET_DEVICE_TYPE_BOORBELL = 0x01,
    SOCKET_DEVICE_TYPE_INDOOR   = 0x02,  

    SOCKET_DEVICE_ALL       = 0xFFFFFFFF,
    SOCKET_DEVICE_ALL_TYPE  = 0xFF000000,
    SOCKET_DEVICE_ALL_UNIT  = 0x00FF0000,
    SOCKET_DEVICE_ALL_FLOOR = 0x0000FF00,
    SOCKET_DEVICE_ALL_INDEX = 0x000000FF,

    
    SOCKET_CMD_DISCOVER = 0x50, /* 搜索设备 */
    SOCKET_CMD_DISCOVER_BACK,

    SOCKET_CMD_HEART_BEAT,      /* 心跳包 */    
    SOCKET_CMD_GET_IP,



}SOCKET_CMD_GROUP;

typedef enum{
    BIT_00 = 0b00000000000000000000000000000001,
    BIT_01 = 0b00000000000000000000000000000010,
    BIT_02 = 0b00000000000000000000000000000100,
    BIT_03 = 0b00000000000000000000000000001000,
    BIT_04 = 0b00000000000000000000000000010000,
    BIT_05 = 0b00000000000000000000000000100000,
    BIT_06 = 0b00000000000000000000000001000000,
    BIT_07 = 0b00000000000000000000000010000000,

    BIT_08 = 0b00000000000000000000000100000000,
    BIT_09 = 0b00000000000000000000001000000000,
    BIT_10 = 0b00000000000000000000010000000000,
    BIT_11 = 0b00000000000000000000100000000000,
    BIT_12 = 0b00000000000000000001000000000000,
    BIT_13 = 0b00000000000000000010000000000000,
    BIT_14 = 0b00000000000000000100000000000000,
    BIT_15 = 0b00000000000000001000000000000000,

    BIT_16 = 0b00000000000000010000000000000000,
    BIT_17 = 0b00000000000000100000000000000000,
    BIT_18 = 0b00000000000001000000000000000000,
    BIT_19 = 0b00000000000010000000000000000000,
    BIT_20 = 0b00000000000100000000000000000000,
    BIT_21 = 0b00000000001000000000000000000000,
    BIT_22 = 0b00000000010000000000000000000000,
    BIT_23 = 0b00000000100000000000000000000000,
    BIT_24 = 0b00000001000000000000000000000000,

    BIT_25 = 0b00000010000000000000000000000000,
    BIT_26 = 0b00000100000000000000000000000000,
    BIT_27 = 0b00001000000000000000000000000000,
    BIT_28 = 0b00010000000000000000000000000000,
    BIT_29 = 0b00100000000000000000000000000000,
    BIT_30 = 0b01000000000000000000000000000000,
    BIT_31 = 0b10000000000000000000000000000000,

}BIT_GROUP;



int _network_device_init();
int user_socket_cmd_send_format(char cmd, unsigned int arg1, unsigned int arg2, const char *text, const char *addr,unsigned int recvArg);


#endif